<?php
class Range{
	private $min;
	private $max;
	private $range;
	private $page;
	
	function Range($min,$max,$range,$page){
		list($this->min,$this->max,$this->range,$this->page)=array($min,$max,$range,$page);
	}
	
	function getList(){
		$temp_left=$this->page-floor($this->range/2);
		$temp_right=$temp_left+$this->range-1;
		
		//echo $temp_left,',',$temp_right;
		
		if($this->max-$this->min<=$this->range-1){
			$temp_left=$this->min;
			$temp_right=$this->max;
		}
		else
		{
			if($temp_right>$this->max){
				$dx=$temp_right-$this->max;
				$temp_left-=$dx;
				$temp_right-=$dx;
			}
			
			if($temp_left<$this->min){
				$dx=$this->min-$temp_left;
				$temp_left+=$dx;
				$temp_right+=$dx;
			}
		}
		
		$ret=array();
		
		for($i=$temp_left;$i<=$temp_right;$i++){
			$ret[]=$i;
		}
		
		return $ret;
	}
}